﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="stable/static/css/site.css" rel="stylesheet" type="text/css">
    <link href="stable/static/css/print.css" rel="stylesheet" type="text/css" media="print">
    <link href="stable/static/css/prettify.css" rel="stylesheet" type="text/css">
    <link href="//www.google.com/images/icons/product/chrome-16.png" rel="icon" type="image/ico">
    <link href="stable/static/css/api.css" rel="stylesheet" type="text/css">
    <title>右键菜单 - chrome插件中文开发文档(非官方)</title>
</head>
<body>
    <a id="top"></a>
    <div id="header">{Header content}</div>
    <a id="gc-topnav-anchor"></a>
    <div id="gc-topnav">
        <h1>chrome插件中文开发文档(非官方)</h1>
        <ul id="home" class="gc-topnav-tabs">
            <li id="home_link">
                <a href="index.html" title="Google Chrome Extensions home page">
                    <div>主页</div>
                </a>
            </li>
            <li id="docs_link">
                <a href="docs.html" title="Official Google Chrome Extensions documentation">
                    <div>文档</div>
                </a>
            </li>
            <li id="faq_link">
                <a href="faq.html" title="Answers to frequently asked questions about Google Chrome Extensions">
                    <div>常见问题</div>
                </a>
            </li>
            <li id="samples_link">
                <a href="samples.html" title="Sample Extensions (with source code)">
                    <div>示例</div>
                </a>
            </li>
            <li id="group_link">
                <a href="http://groups.google.com/a/chromium.org/group/chromium-extensions" title="Google Chrome Extensions developer forum">
                    <div>google群组(英文)</div>
                </a>
            </li>
            <li id="so_link">
                <a href="http://stackoverflow.com/questions/tagged/google-chrome-extension" title="[google-chrome-extension] tag on Stack Overflow">
                    <div>还有问题?(英文)</div>
                </a>
            </li>
        </ul>
    </div>
    <div id="gc-container">
        <div id="gc-sidebar">
            <ul
                class="level1 ">
                <li class="level2">
                    <a href="getstarted.html" class="level2 ">入门</a>
                </li>
                <li class="level2">
                    <a href="overview.html" class="level2 ">概述</a>
                </li>
                <li class="level2">
                    <a href="whats_new.html" class="level2 ">新功能</a>
                </li>
                <li class="level2">
                    <a href="devguide.html" class="level2 ">开发者指南</a>
                    <ul
                        class="level2 ">
                        <li class="level3">
                            <a class="button level3">
                                <span class="level3">用户界面</span>
                                <div class="toggleIndicator level3"></div>
                            </a>
                            <ul toggleable
                                class="level3 hidden">
                                <li class="level4">
                                    <a href="browserAction.html" class="level4 ">浏览器按钮</a>
                                </li>
                                <li class="level4">
                                    <a href="contextMenus.html" class="level4 ">右键菜单</a>
                                </li>
                                <li class="level4">
                                    <a href="notifications.html" class="level4 ">桌面通知</a>
                                </li>
                                <li class="level4">
                                    <a href="omnibox.html" class="level4 ">多功能地址栏</a>
                                </li>
                                <li class="level4">
                                    <a href="options.html" class="level4 ">选项页面</a>
                                </li>
                                <li class="level4">
                                    <a href="override.html" class="level4 ">代替页面</a>
                                </li>
                                <li class="level4">
                                    <a href="pageAction.html" class="level4 ">页面按钮</a>
                                </li>
                            </ul>
                        </li>
                        <li class="level3">
                            <a class="button level3">
                                <span class="level3">浏览器交互</span>
                                <div class="toggleIndicator level3"></div>
                            </a>
                            <ul toggleable
                                class="level3 hidden">
                                <li class="level4">
                                    <a href="bookmarks.html" class="level4 ">书签</a>
                                </li>
                                <li class="level4">
                                    <a href="cookies.html" class="level4 ">Cookies</a>
                                </li>
                                <li class="level4">
                                    <a href="devtools.html" class="level4 ">开发人员工具</a>
                                </li>
                                <li class="level4">
                                    <a href="events.html" class="level4 ">事件</a>
                                </li>
                                <li class="level4">
                                    <a href="history.html" class="level4 ">历史记录</a>
                                </li>
                                <li class="level4">
                                    <a href="management.html" class="level4 ">管理</a>
                                </li>
                                <li class="level4">
                                    <a href="tabs.html" class="level4 ">标签页</a>
                                </li>
                                <li class="level4">
                                    <a href="windows.html" class="level4 ">窗口</a>
                                </li>
                            </ul>
                        </li>
                        <li class="level3">
                            <a class="button level3">
                                <span class="level3">实现</span>
                                <div class="toggleIndicator level3"></div>
                            </a>
                            <ul toggleable
                                class="level3 hidden">
                                <li class="level4">
                                    <a href="a11y.html" class="level4 ">辅助功能</a>
                                </li>
                                <li class="level4">
                                    <a href="event_pages.html" class="level4 ">事件页面</a>
                                </li>
                                <li class="level4">
                                    <a href="contentSecurityPolicy.html" class="level4 ">内容安全策略(CSP)</a>
                                </li>
                                <li class="level4">
                                    <a href="content_scripts.html" class="level4 ">内容脚本</a>
                                </li>
                                <li class="level4">
                                    <a href="xhr.html" class="level4 ">跨站XMLHttpRequest</a>
                                </li>
                                <li class="level4">
                                    <a href="i18n.html" class="level4 ">国际化</a>
                                </li>
                                <li class="level4">
                                    <a href="messaging.html" class="level4 ">消息传递</a>
                                </li>
                                <li class="level4">
                                    <a href="permissions.html" class="level4 ">可选权限</a>
                                </li>
                                <li class="level4">
                                    <a href="npapi.html" class="level4 ">NPAPI插件</a>
                                </li>
                            </ul>
                        </li>
                        <li class="level3">
                            <a class="button level3">
                                <span class="level3">完成</span>
                                <div class="toggleIndicator level3"></div>
                            </a>
                            <ul toggleable
                                class="level3 hidden">
                                <li class="level4">
                                    <a href="hosting.html" class="level4 ">托管</a>
                                </li>
                                <li class="level4">
                                    <a href="external_extensions.html" class="level4 ">其他部署方案</a>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </li>
                <li class="level2">
                    <a href="tutorials.html" class="level2 ">教程</a>
                    <ul
                        class="level2 ">
                        <li class="level3">
                            <a href="tut_migration_to_manifest_v2.html" class="level3 ">清单文件V2</a>
                        </li>
                        <li class="level3">
                            <a href="tut_debugging.html" class="level3 ">调试</a>
                        </li>
                        <li class="level3">
                            <a href="tut_analytics.html" class="level3 ">Google Analytics(分析)</a>
                        </li>
                        <li class="level3">
                            <a href="tut_oauth.html" class="level3 ">OAuth</a>
                        </li>
                    </ul>
                </li>
                <li class="level2">
                    <span class="level2">参考</span>
                    <ul
                        class="level2 ">
                        <li class="level3">
                            <a class="button level3">
                                <span class="level3">格式</span>
                                <div class="toggleIndicator level3"></div>
                            </a>
                            <ul toggleable
                                class="level3 hidden">
                                <li class="level4">
                                    <a href="manifest.html" class="level4 ">清单文件</a>
                                </li>
                                <li class="level4">
                                    <a href="match_patterns.html" class="level4 ">匹配表达式</a>
                                </li>
                            </ul>
                        </li>
                        <li class="level3">
                            <a href="permission_warnings.html" class="level3 ">权限警告</a>
                        </li>
                        <li class="level3">
                            <a href="api_index.html" class="level3 ">chrome.* APIs</a>
                        </li>
                        <li class="level3">
                            <a href="api_other.html" class="level3 ">其他APIs</a>
                        </li>
                    </ul>
                </li>
                <li class="level2">
                    <span class="level2">更多</span>
                    <ul
                        class="level2 ">
                        <li class="level3">
                            <a href="http://code.google.com/chrome/webstore/docs/index.html" class="level3 ">chrome商店</a>
                        </li>
                        <li class="level3">
                            <a href="http://code.google.com/chrome/apps/docs/developers_guide.html" class="level3 ">托管应用程序</a>
                        </li>
                        <li class="level3">
                            <a href="themes.html" class="level3 ">主题</a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
        <div id="gc-pagecontent">
            <h1 class="page_title">右键菜单（chrome.contextMenus)</h1>



            <div id="toc">
                <h2>内容</h2>
                <ol>
                    <li>
                        <a href="#manifest">清单文件</a>
                    </li>
                    <li>
                        <a href="#examples">示例</a>
                    </li>
                    <li>
                        <a href="#apiReference">API参考： chrome.contextMenus</a>
                        <ol>
                            <li><a href="#types">类型</a><ol>
                                <li><a href="#type-OnClickData">OnClickData</a>  </li>
                            </ol>
                            </li>

                            <li><a href="#methods">方法</a><ol>
                                <li><a href="#method-create">create</a></li>
                                <li><a href="#method-update">update</a></li>
                                <li><a href="#method-remove">remove</a></li>
                                <li><a href="#method-removeAll">removeAll</a></li>
                            </ol>
                            </li>
                            <li><a href="#events">事件</a><ol>
                                <li><a href="#event-onClicked">onClicked</a></li>
                            </ol>
                            </li>
                            <li><a href="#samples">示例扩展</a></li>
                        </ol>
                    </li>
                </ol>
            </div>

            <p>
                右键菜单模块允许您向Google Chrome浏览器的右键菜单添加项目
            </p>

            <p>
                您可以选择您在右键菜单中添加的项目应用于哪些类型的对象，例如图片、超链接和页面。
            </p>

            <p>
                您可以根据自己的需要创建任意数目的右键菜单项，但是如果您的扩展程序一次显示超过一个菜单项，Google Chrome浏览器会自动将它们折叠至一个父菜单中。
            </p>

            <p>
                右键菜单项可以在任何文档（或文档中的框架）中出现，即使它们使用file://或chrome://协议的URL。要控制您的菜单项在哪些文档中出现，在您调用create()或update()方法时请指定documentUrlPatterns属性。
            </p>

            <h2 id="manifest">清单文件</h2>
            <p>
                您必须在扩展程序的清单文件中声明"contextMenus"权限来使用有关API，您还应该指定一个16×16像素的图标，显示在您的菜单项旁边。例如：
            </p>

            <pre>{
  "name": "我的扩展程序",
  ...
  "permissions": [
    <b>"contextMenus"</b>
  ],
  "icons": {
    <b>"16": "icon-bitty.png",</b>
    "48": "icon-small.png",
    "128": "icon-large.png"
  },
  ...
}</pre>

            <h2 id="examples">例子</h2>

            <p>
                您可以在
                <a href="samples.html#contextMenus">示例页面</a>找到这一API的示例。
       
                <h2 id="apiReference">API参考: chrome.contextMenus</h2>
                <div class="api_reference">
                    <h3 id="types">类型</h3>
                    <div>
                        <h3 id="type-OnClickData">OnClickData</h3>
                        <div>
                            <dt><span class="type_name">(    <span id="typeTemplate">object</span>  )</span></dt>
                            <dd>包含右键菜单项单击时发送的信息。
                  </dd>
                            <h4 id="OnClickData-properties"><a href="#type-OnClickData">OnClickData</a>属性
                            </h4>
                            <dd>
                                <dl>
                                    <div>
                                        <a name="property-OnClickData-menuItemId"></a>
                                        <dt>
                                            <span class="variable">menuItemId</span>
                                            <span class="property">(
                            
                           

                                                <span id="typeTemplate">integer or string</span>
                                                )
                        </span>
                                        </dt>
                                        <dd>单击的菜单项标识符。
                      </dd>
                                    </div>
                                    <div>
                                        <a name="property-OnClickData-parentMenuItemId"></a>
                                        <dt>
                                            <span class="variable">parentMenuItemId</span>
                                            <span class="property">(
                           
                                                <span class="optional">optional</span>
                                                <span id="typeTemplate">integer or string</span>
                                                )
                        </span>
                                        </dt>
                                        <dd>单击的菜单项的父菜单项标识符（如果有的话）。
                      </dd>
                                    </div>
                                    <div>
                                        <a name="property-OnClickData-mediaType"></a>
                                        <dt>
                                            <span class="variable">mediaType</span>
                                            <span class="property">(
                           
                                                <span class="optional">optional</span>
                                                <span id="typeTemplate">string</span>
                                                )
                        </span>
                                        </dt>
                                        <dd>如果右键菜单在其中某一种类型的元素上激活则值为'image'、'video'或'audio'。
                      </dd>
                                    </div>
                                    <div>
                                        <a name="property-OnClickData-linkUrl"></a>
                                        <dt>
                                            <span class="variable">linkUrl</span>
                                            <span class="property">(
                           
                                                <span class="optional">optional</span>
                                                <span id="typeTemplate">string</span>
                                                )
                        </span>
                                        </dt>
                                        <dd>如果元素是一个链接，指定它指向的URL。
                      </dd>
                                    </div>
                                    <div>
                                        <a name="property-OnClickData-srcUrl"></a>
                                        <dt>
                                            <span class="variable">srcUrl</span>
                                            <span class="property">(
                           
                                                <span class="optional">optional</span>
                                                <span id="typeTemplate">string</span>
                                                )
                        </span>
                                        </dt>
                                        <dd>如果元素的'src'属性指定了URL将会存在这一属性。
                      </dd>
                                    </div>
                                    <div>
                                        <a name="property-OnClickData-pageUrl"></a>
                                        <dt>
                                            <span class="variable">pageUrl</span>
                                            <span class="property">(
                            
                           

                                                <span id="typeTemplate">string</span>
                                                )
                        </span>
                                        </dt>
                                        <dd>菜单项单击时所在页面的URL。
                      </dd>
                                    </div>
                                    <div>
                                        <a name="property-OnClickData-frameUrl"></a>
                                        <dt>
                                            <span class="variable">frameUrl</span>
                                            <span class="property">(
                           
                                                <span class="optional">optional</span>
                                                <span id="typeTemplate">string</span>
                                                )
                        </span>
                                        </dt>
                                        <dd>如果在框架中的话，单击后弹出右键菜单时框架元素的URL。
                      </dd>
                                    </div>
                                    <div>
                                        <a name="property-OnClickData-selectionText"></a>
                                        <dt>
                                            <span class="variable">selectionText</span>
                                            <span class="property">(
                           
                                                <span class="optional">optional</span>
                                                <span id="typeTemplate">string</span>
                                                )
                        </span>
                                        </dt>
                                        <dd>当前选中的文本（如果有的话）。
                      </dd>
                                    </div>
                                    <div>
                                        <a name="property-OnClickData-editable"></a>
                                        <dt>
                                            <span class="variable">editable</span>
                                            <span class="property">(
                            
                           

                                                <span id="typeTemplate">boolean</span>
                                                )
                        </span>
                                        </dt>
                                        <dd>一个标志，指定当前元素是否可以编辑 (text input, textarea, 等)。
                      </dd>
                                    </div>
                                    <div>
                                        <a name="property-OnClickData-wasChecked"></a>
                                        <dt>
                                            <span class="variable">wasChecked</span>
                                            <span class="property">(
                           
                                                <span class="optional">optional</span>
                                                <span id="typeTemplate">boolean</span>
                                                )
                        </span>
                                        </dt>
                                        <dd>指示单击前复选框或单选菜单项状态的标志。
                      </dd>
                                    </div>
                                    <div>
                                        <a name="property-OnClickData-checked"></a>
                                        <dt>
                                            <span class="variable">checked</span>
                                            <span class="property">(
                           
                                                <span class="optional">optional</span>
                                                <span id="typeTemplate">boolean</span>
                                                )
                        </span>
                                        </dt>
                                        <dd>指示单击后复选框或单选菜单项状态的标志。
                      </dd>
                                    </div>
                                </dl>
                            </dd>
                        </div>
                    </div>
                    <h3 id="methods">方法</h3>
                    <div>
                        <h4 id="method-create">create</h4>
                        <div class="summary">
                            <span>integer or string chrome.contextMenus.create</span>(<span>object <span class="variable">createProperties</span></span>)
               
                        </div>
                        <div class="description">
                            <p>
                                创建一个新的右键菜单项。注意，如果创建过程中发生错误，您可能要等到回调函数调用时才能得知（详情可从chrome.runtime.lastError获得）
                 
                            </p>
                            <h4>参数</h4>
                            <dl>
                                <div><a name="property-create-createProperties"></a>
                                    <dt><span class="variable">createProperties</span>    <span class="property">(                <span id="typeTemplate">object</span>      )    </span></dt>
                                    <dd>
                                        <dl>
                                            <div><a name="property-createProperties-type"></a>
                                                <dt><span class="variable">type</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">enumerated string ["normal", "checkbox", "radio", "separator"]</span>            )          </span></dt>
                                                <dd>菜单项的类型。如果没有指定则默认为'normal'（普通）。     </dd>
                                            </div>
                                            <div><a name="property-createProperties-id"></a>
                                                <dt><span class="variable">id</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">string</span>            )          </span></dt>
                                                <dd>指派给该菜单项的唯一标志符，对于事件页面来说必须存在，不能与同一扩展程序中的其它标志符相同。   </dd>
                                            </div>
                                            <div><a name="property-createProperties-title"></a>
                                                <dt><span class="variable">title</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">string</span>            )          </span></dt>
                                                <dd>显示在菜单项中的文字，除非<em>类型</em>是'separator'（分隔符）该参数是<em>必选</em>的。 当上下文为'selection'（选定内容）时，您可以在字符串中使用<code>%s</code>来显示选中的文本。例如，如果参数值是“将‘%s’翻译为儿童黑话”，当用户选择一个词语“酷”时，对于选中内容的右键菜单项为“将‘酷’翻译为儿童黑话”。</dd>
                                            </div>
                                            <div><a name="property-createProperties-checked"></a>
                                                <dt><span class="variable">checked</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">boolean</span>            )          </span></dt>
                                                <dd>单选或复选菜单项的初始状态：选定为true，未选定为false。在一组单选菜单项中，一次只能有一项选定。        </dd>
                                            </div>
                                            <div><a name="property-createProperties-contexts"></a>
                                                <dt><span class="variable">contexts</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">array of enumerated string ["all", "page", "frame", "selection", "link", "editable", "image", "video", "audio"]</span>            )          </span></dt>
                                                <dd>列出该菜单项将会出现在哪些上下文中，包括"all"（全部）、"page"（页面）、"frame"（框架）、"selection"（选定内容）、"link"（链接）、"editable"（可编辑内容）、"image"（图片）、"video"（视频）、"audio"（音频），如果没有指定则默认为['page']（页面）     </dd>
                                            </div>
                                            <div><a name="property-createProperties-onclick"></a>
                                                <dt><span class="variable">onclick</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">function</span>            )          </span></dt>
                                                <dd>当菜单项单击时的回调函数。事件页面不能使用该属性，相反，它们应该为chrome.contextMenus.onClicked注册事件处理函数。       </dd>
                                                <dd>
                                                    <dl>
                                                        <h5>参数</h5>
                                                        <div><a name="property-onclick-info"></a>
                                                            <dt><span class="variable">info</span>                <span class="property">(                                        <span id="typeTemplate"><a href="contextMenus.html#type-OnClickData">OnClickData</a></span>                  )                </span></dt>
                                                            <dd>有关单击发生时的菜单项和上下文的信息。             </dd>
                                                        </div>
                                                        <div><a name="property-onclick-tab"></a>
                                                            <dt><span class="variable">tab</span>                <span class="property">(                                        <span id="typeTemplate"><a href="tabs.html#type-Tab">tabs.Tab</a></span>                  )                </span></dt>
                                                            <dd>单击发生的标签页的细节。         </dd>
                                                        </div>
                                                    </dl>
                                                </dd>
                                            </div>
                                            <div><a name="property-createProperties-parentId"></a>
                                                <dt><span class="variable">parentId</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">integer or string</span>            )          </span></dt>
                                                <dd>父菜单项标识符，指定这一参数使新添加的菜单项成为原先添加菜单项的子菜单项。       </dd>
                                            </div>
                                            <div><a name="property-createProperties-documentUrlPatterns"></a>
                                                <dt><span class="variable">documentUrlPatterns</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">array of string</span>            )          </span></dt>
                                                <dd>让您将该菜单项限制在URL匹配给定表达式的文档中显示。（也适用于框架。）有关表达式的格式的细节，参见<a href='match_patterns.html'>匹配表达式</a>。        </dd>
                                            </div>
                                            <div><a name="property-createProperties-targetUrlPatterns"></a>
                                                <dt><span class="variable">targetUrlPatterns</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">array of string</span>            )          </span></dt>
                                                <dd>类似于documentUrlPatterns，但是允许您基于img/audio/video标签的src属性以及 a 标签的href属性过滤。      </dd>
                                            </div>
                                            <div><a name="property-createProperties-enabled"></a>
                                                <dt><span class="variable">enabled</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">boolean</span>            )          </span></dt>
                                                <dd>该右键菜单项是否启用或禁用，默认为true。      </dd>
                                            </div>
                                        </dl>
                                    </dd>
                                </div>
                            </dl>
                            <h4>回调函数</h4>
                            <p>如果您指定了<em>callback</em>参数, 它应该指定一个如下形式的函数：</p>
                            <pre>function() <span class="subdued">{...}</span>;</pre>
                            <dl></dl>
                        </div>
                    </div>
                    <div>
                        <h4 id="method-update">update</h4>
                        <div class="summary lower">
                            <span>chrome.contextMenus.update</span>(<span>integer or string <span class="variable">id</span></span>, <span>object <span class="variable">updateProperties</span></span>)
               
                        </div>
                        <div class="description">
                            <p>
                                更新以前创建的菜单项。
                 
                            </p>
                            <h4>参数</h4>
                            <dl>
                                <div><a name="property-update-id"></a>
                                    <dt><span class="variable">id</span>    <span class="property">(                <span id="typeTemplate">integer or string</span>      )    </span></dt>
                                    <dd>要更新的菜单项标识符。 </dd>
                                </div>
                                <div><a name="property-update-updateProperties"></a>
                                    <dt><span class="variable">updateProperties</span>    <span class="property">(                <span id="typeTemplate">object</span>      )    </span></dt>
                                    <dd>要更新的属性，与create函数的createProperties参数使用的相同值  </dd>
                                    <dd>
                                        <dl>
                                            <div><a name="property-updateProperties-type"></a>
                                                <dt><span class="variable">type</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">enumerated string ["normal", "checkbox", "radio", "separator"]</span>            )          </span></dt>
                                            </div>
                                            <div><a name="property-updateProperties-title"></a>
                                                <dt><span class="variable">title</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">string</span>            )          </span></dt>
                                            </div>
                                            <div><a name="property-updateProperties-checked"></a>
                                                <dt><span class="variable">checked</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">boolean</span>            )          </span></dt>
                                            </div>
                                            <div><a name="property-updateProperties-contexts"></a>
                                                <dt><span class="variable">contexts</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">array of enumerated string ["all", "page", "frame", "selection", "link", "editable", "image", "video", "audio"]</span>            )          </span></dt>
                                            </div>
                                            <div><a name="property-updateProperties-onclick"></a>
                                                <dt><span class="variable">onclick</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">function</span>            )          </span></dt>
                                            </div>
                                            <div><a name="property-updateProperties-parentId"></a>
                                                <dt><span class="variable">parentId</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">integer or string</span>            )          </span></dt>
                                                <dd>注意：您不能更改菜单项，使它成为自己的子菜单。       </dd>
                                            </div>
                                            <div><a name="property-updateProperties-documentUrlPatterns"></a>
                                                <dt><span class="variable">documentUrlPatterns</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">array of string</span>            )          </span></dt>
                                            </div>
                                            <div><a name="property-updateProperties-targetUrlPatterns"></a>
                                                <dt><span class="variable">targetUrlPatterns</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">array of string</span>            )          </span></dt>
                                            </div>
                                            <div><a name="property-updateProperties-enabled"></a>
                                                <dt><span class="variable">enabled</span>          <span class="property">(              <span class="optional">optional</span>              <span id="typeTemplate">boolean</span>            )          </span></dt>
                                            </div>
                                        </dl>
                                    </dd>
                                </div>
                            </dl>
                            <h4>回调函数</h4>
                            <p>如果您指定了<em>callback</em>参数，它应该指定一个如下形式的函数：</p>
                            <pre>function() <span class="subdued">{...}</span>;</pre>
                            <dl></dl>
                        </div>
                    </div>
                    <div>
                        <h4 id="method-remove">remove</h4>
                        <div class="summary lower">
                            <span>chrome.contextMenus.remove</span>(<span>integer or string <span class="variable">menuItemId</span></span>)
               
                        </div>
                        <div class="description">
                            <p>
                               移除一个右键菜单项。
                 
                            </p>
                            <h4>参数</h4>
                            <dl>
                                <div><a name="property-remove-menuItemId"></a>
                                    <dt><span class="variable">menuItemId</span>    <span class="property">(                <span id="typeTemplate">integer or string</span>      )    </span></dt>
                                    <dd>要移除的菜单项标识符。 </dd>
                                </div>
                            </dl>
                            <h4>Callback function</h4>
                            <p>如果您指定了<em>callback</em>参数，它应该指定一个如下形式的函数：</p>
                            <pre>function() <span class="subdued">{...}</span>;</pre>
                            <dl></dl>
                        </div>
                    </div>
                    <div>
                        <h4 id="method-removeAll">removeAll</h4>
                        <div class="summary lower">
                            <span>chrome.contextMenus.removeAll</span>()
               
                        </div>
                        <div class="description">
                            <p>
                                移除该扩展程序添加的所有右键菜单项。
                 
                            </p>
                        </div>
                    </div>
                    <h3 id="events">事件</h3>
                    <div>
                        <h4 id="event-onClicked">onClicked</h4>
                        <div class="summary">
                            <span class="subdued">chrome.contextMenus.</span>onClicked<span class="subdued">.addListener</span>(function(<span><a href="contextMenus.html#type-OnClickData">OnClickData</a> <span class="variable">info</span></span>, <span class="optional"><a href="tabs.html#type-Tab">tabs.Tab</a> <span class="variable">tab</span></span>)<span class="subdued"> {...}</span>);
               
                        </div>
                        <div class="description">
                            <p>
                                当右键菜单项单击时产生。
                 
                            </p>
                            <h4>监听参数</h4>
                            <dl>
                                <div><a name="property-onClicked-info"></a>
                                    <dt><span class="variable">info</span>    <span class="property">(                <span id="typeTemplate"><a href="contextMenus.html#type-OnClickData">OnClickData</a></span>      )    </span></dt>
                                    <dd>有关单击发生时的菜单项和上下文的信息。  </dd>
                                </div>
                                <div><a name="property-onClicked-tab"></a>
                                    <dt><span class="variable">tab</span>    <span class="property">(        <span class="optional">optional</span>        <span id="typeTemplate"><a href="tabs.html#type-Tab">tabs.Tab</a></span>      )    </span></dt>
                                    <dd>单击发生的标签页的细节。如果单击不在标签页中产生，将不会传递该参数。 </dd>
                                </div>
                            </dl>
                        </div>
                    </div>
                </div>
                <h2 id="samples">使用chrome.contextMenus的示例程序</h2>
                <li><strong><a href="samples.html#ea5374398da2255f743fd37964100fed">Context Menus Sample</a></strong> &ndash;
            Shows some of the features of the Context Menus API
        </li>
                <li><strong><a href="samples.html#e0410b3575a19930b8cf73f1e5acee0a">Context Menus Sample (with Event Page)</a></strong> &ndash;
            Shows some of the features of the Context Menus API using an event page
        </li>
                <li><strong><a href="samples.html#93904b0c2be99bc6dad7609b132a905e">Imageinfo</a></strong> &ndash;
            Get image info for images, including EXIF data
        </li>
        </div>
    </div>
</body>
<script>
    window.bootstrap = {
        api_names: [{ "name": "alarms" }, { "name": "bookmarks" }, { "name": "browserAction" }, { "name": "browsingData" }, { "name": "commands" }, { "name": "contentSettings" }, { "name": "contextMenus" }, { "name": "cookies" }, { "name": "debugger" }, { "name": "declarativeWebRequest" }, { "name": "devtools.inspectedWindow" }, { "name": "devtools.network" }, { "name": "devtools.panels" }, { "name": "downloads" }, { "name": "events" }, { "name": "extension" }, { "name": "fileBrowserHandler" }, { "name": "fontSettings" }, { "name": "history" }, { "name": "i18n" }, { "name": "idle" }, { "name": "input.ime" }, { "name": "management" }, { "name": "omnibox" }, { "name": "pageAction" }, { "name": "pageCapture" }, { "name": "permissions" }, { "name": "privacy" }, { "name": "proxy" }, { "name": "runtime" }, { "name": "scriptBadge" }, { "name": "storage" }, { "name": "tabs" }, { "name": "topSites" }, { "name": "tts" }, { "name": "ttsEngine" }, { "name": "types" }, { "name": "webNavigation" }, { "name": "webRequest" }, { "name": "webstore" }, { "last": true, "name": "windows" }].concat(
            [{ "name": "experimental.bluetooth" }, { "name": "experimental.devtools.audits" }, { "name": "experimental.devtools.console" }, { "name": "experimental.discovery" }, { "name": "experimental.identity" }, { "name": "experimental.infobars" }, { "name": "experimental.offscreenTabs" }, { "name": "experimental.processes" }, { "name": "experimental.record" }, { "name": "experimental.speechInput" }, { "name": "experimental.systemInfo.cpu" }, { "name": "experimental.systemInfo.storage" }, { "last": true, "name": "experimental.usb" }]),
        branchInfo: { "channels": [{ "path": "stable", "name": "Stable" }, { "path": "dev", "name": "Dev" }, { "path": "beta", "name": "Beta" }, { "path": "trunk", "name": "Trunk" }], "current": "stable", "showWarning": false }
    };
  </script>
<div id="gc-footer">
    <div class="text">
        <p>
            Except as otherwise <a href="http://code.google.com/policies.html#restrictions">noted</a>,
        the content of this page is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons
        Attribution 3.0 License</a>, and code samples are licensed under the
       
            <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD License</a>.
     
        </p>
        <p>
            ©2012 Google
     
        </p>
        <script src="stable/static/js/branch.js" type="text/javascript"></script>
        <script src="stable/static/js/sidebar.js" type="text/javascript"></script>
        <script src="stable/static/js/prettify.js" type="text/javascript"></script>
        <script>
            (function () {
                // Auto syntax highlight all pre tags.
                var preElements = document.getElementsByTagName('pre');
                for (var i = 0; i < preElements.length; i++)
                    preElements[i].classList.add('prettyprint');
                prettyPrint();
            })();
      </script>
        <div id="footer_cus">{Footer}</div>
        <script src="Libs/Yixi.js"></script>
        <script src="http://s9.cnzz.com/stat.php?id=4928336&web_id=4928336" language="JavaScript"></script>

    </div>
</div>
</html>
